package com.zzyl.serve.controller;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.core.page.TableDataInfo;
import com.zzyl.nursing.dto.RescheduleTaskForm;
import com.zzyl.serve.domain.NursingTask;
import com.zzyl.serve.dto.DoDto;
import com.zzyl.serve.dto.NursingTaskDto;
import com.zzyl.serve.service.INursingTaskService;
import com.zzyl.serve.vo.IdTaskVo;
import com.zzyl.serve.vo.NursingTaskVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.zzyl.common.utils.PageUtils.startPage;

/**
 * TODO
 *
 * @Author mr.wu
 * @Date 2025/10/29 16:39
 */
@RestController
@Slf4j
@RequestMapping("/nursing/nursingTask")
public class NursingTaskController extends BaseController {

    @Autowired
    private INursingTaskService nursingTaskService;
    @GetMapping("/list")
    public TableDataInfo tasklist(NursingTaskDto dto) {
        log.info("查询护理任务列表");
        startPage();
        List<NursingTaskVO> list =nursingTaskService.tasklist(dto);
        return  getDataTable(list);
    }
    @PutMapping("/cancel")
    public AjaxResult cancel(@RequestBody NursingTaskDto dto){
        log.info("取消任务");
       nursingTaskService.cancelTask(dto.getReason(),dto.getTaskId());
       return success();
    }
    @PutMapping("/do")
    public AjaxResult doTask(@RequestBody DoDto dto){
        log.info("执行任务");
        nursingTaskService.doTask(dto);
        return success();
    }
    @PutMapping("/updateTime")
    public  AjaxResult updateTime(@RequestBody RescheduleTaskForm rescheduleTaskForm){
        log.info("更新任务时间");
        nursingTaskService.updateTime(rescheduleTaskForm);
        return success();
    }
    @GetMapping("/{id}")
    public AjaxResult getByid(@PathVariable Long id){
        log.info("查询任务详情");
        IdTaskVo taskVo = nursingTaskService.getByid(id);
        return success(taskVo);
    }
}